<template>
  <div class="edit-main">
    <left v-if="page"></left>
    <div class="edit-zone">
      <div class="edit-page-editor">
        <div class="edit-component-con" @click.stop="onHiddenPop">
          <div class="standard-line"></div>
          <middle v-if="page"></middle>
          <shortcut-key></shortcut-key>
          <div v-if="siteStatus.isCopySite" class="copy-site-data-con">
            <el-input type="textarea" placeholder="请输入站点数据" v-model="copySiteData" @change="setSiteData"></el-input>
          </div>
        </div>
        <right></right>
      </div>
      <RightTimeLine></RightTimeLine>
    </div>
  </div>
</template>

<script>
import Left from '@/views/child/Left.vue'
import Middle from '@/views/child/Middle.vue'
import ShortcutKey from '@/views/child/ShortcutKey.vue'
import Right from '@/views/child/Right.vue'
import RightTimeLine from '@/views/child/right/right-timeline.vue'
import { mapState, mapActions } from 'vuex'
import { copySiteData } from '@/common/site-data'

export default {
  name: "MainContent",
  data() {
    return {
      copySiteData: ""
    };
  },
  components: {
    Left,
    Middle,
    ShortcutKey,
    Right,
    RightTimeLine
  },
  created () {
    let isLocalData = false
    if(isLocalData){
      window.localStorage.siteData = JSON.stringify(copySiteData);
      this.$store.dispatch("components/setLocalData");
    }else{
      this.$store.dispatch("components/getPageDatas", {id: this.$route.params.id});
    }
  },
  computed: {
    ...mapState("components", {
      siteStatus: state => state.siteStatus,
      siteId: state => state.id,
      page: state => state.currentPage,
    })
  },
  methods: {
    ...mapActions({
      setRightMenuStatus: "components/setRightMenuStatus",
      hiddenMediaPop: 'hiddenMediaPop',
    }),
    onHiddenPop(){
      this.hiddenMediaPop();
      this.setRightMenuStatus({ isVisible:false, left:0, top:'-1000px'  })
    },
    setSiteData(){
      let copySiteData = JSON.parse(this.copySiteData);
      copySiteData.id = this.siteId;
      window.localStorage.siteData = JSON.stringify(copySiteData);
      this.$store.dispatch("components/setLocalData");
    }
  }
};
</script>

<style lang="scss">
@import '@/assets/css/edit-mobile.scss';
</style>
